package com.spzx.test1.Day3Test;
/*
    并非全力
*/

import java.util.concurrent.Semaphore;

import static java.lang.Thread.sleep;

public class t1 {

    public  int count = 1;
    public static void main(String[] args) {
        Semaphore semaphore = new Semaphore(3);


        for (int count = 1; count < 11; count++) {


            int finalCount = count;
            new Thread(() -> {
                try {
                    semaphore.acquire();
                    System.out.println("running..."+ finalCount);
                    sleep(2);
                    System.out.println("end..");
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }finally {
                    semaphore.release();
                }
            }).start();


        }

    }
}
